package net.fpeg.kotlin.msa.auth.controller

import net.fpeg.kotlin.msa.auth.dto.BaseDto
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.ControllerAdvice
import org.springframework.web.bind.annotation.ExceptionHandler
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.ResponseStatus


@ControllerAdvice
class ControllerExceptionHandler {
    @ExceptionHandler(Exception::class)
    @ResponseBody
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    fun handleRecordExistException(ex: Exception): BaseDto {
        return BaseDto(ex.message.toString())
    }
}